Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / util / NetworkTransportInfo.kt

Displaying Raw • Download

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/util/NetworkTransportInfo.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 4.08 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.util

T8b949e/**
* Transport-type snapshot of a single system network. Filled in by the platform-specific `isWifiUnavailable` actual
* (Android's `ConnectivityManager.getNetworkCapabilities`); kept platform-agnostic so the "is any network-scan
* transport present?" reduction is unit-testable from `commonTest` without an Android runtime.
*/
Tff7b72internal Tff7b72data Tff7b72class T56d364NetworkTransportInfoTb4b4b4(Tff7b72val Te6edf3hasWifiTb4b4b4: Tffa657BooleanTb4b4b4, Tff7b72val Te6edf3hasEthernetTb4b4b4: Tffa657BooleanTb4b4b4, Tff7b72val Te6edf3hasVpnTb4b4b4: Tffa657BooleanTb4b4b4)

T8b949e/**
* Returns `true` if any of the provided [networks] exposes a Wi-Fi, Ethernet, or VPN transport — the three transports
* that can carry TCP traffic to a Meshtastic node and therefore serve as a valid backing path for the network-scan
* (NSD/mDNS or direct-IP) discovery used by `ConnectionsScreen`. Drives the `wifiUnavailable` recovery banner: as long
* as *any* current network is Wi-Fi, Ethernet, or VPN, the banner stays cleared, regardless of whether the system has
* selected one of them as the default route.
*
* VPN (e.g. ZeroTier, Tailscale) is intentionally included because TCP nodes are routinely reachable over a routed
* overlay just as over a physical LAN. Cellular is intentionally **excluded** — a carrier uplink alone does not put the
* device on the same L2/L3 segment as a Meshtastic node, so cellular-only must keep the banner shown.
*
* This reduction deliberately does **not** require `NET_CAPABILITY_VALIDATED` or `NET_CAPABILITY_INTERNET`: a local
* mesh access point or a VPN without upstream may be unvalidated yet still carry the TCP traffic the scan needs. The
* previous implementation only inspected the default network and only recognized Wi-Fi/Ethernet, so the banner stayed
* stuck whenever Android kept cellular as default (or Wi-Fi was connected but unvalidated), and failed to clear when a
* VPN provided the actual reachability path.
*/
Tff7b72internal Tff7b72fun Td2a8ffanyNetworkScanTransportAvailableTb4b4b4(Te6edf3networksTb4b4b4: Te6edf3ListTff7b72<Te6edf3NetworkTransportInfoTff7b72>Tb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72=
Te6edf3networksTb4b4b4.Te6edf3any Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3hasWifi Tff7b72|Tff7b72| Tffa657itTb4b4b4.Te6edf3hasEthernet Tff7b72|Tff7b72| Tffa657itTb4b4b4.Te6edf3hasVpn Tb4b4b4}

T8b949e/**
* Returns `true` when the "Wi-Fi unavailable" recovery banner should render in `ConnectionsScreen`.
*
* Banner shows only while a network scan is actively running, local-network permission is granted, WiFi is unavailable,
* and the scan has not yet produced any discovered TCP nodes. The auto-scan case is covered because `isNetworkScanning`
* is true during auto-scan regardless of the user's active Connections pane.
*
* Gating on the scan state keeps the banner silent while discovery is idle — the user only needs the recovery hint at
* the moment a scan cannot find a usable transport. The [localNetworkPermissionGranted] guard keeps the banner from
* overlapping the permission-request flow on the scan toggle.
*
* The banner is a recovery hint for the case where the user has started a network scan but no nodes have been
* discovered yet. Once the scan produces results, the user has found what they were looking for and the hint is no
* longer useful — so the banner is suppressed when the discovered-TCP list is non-empty.
*/
Tff7b72fun Td2a8ffshouldShowWifiUnavailableBannerTb4b4b4(
Te6edf3isNetworkScanningTb4b4b4: Tffa657BooleanTb4b4b4,
Te6edf3localNetworkPermissionGrantedTb4b4b4: Tffa657BooleanTb4b4b4,
Te6edf3wifiUnavailableTb4b4b4: Tffa657BooleanTb4b4b4,
Te6edf3discoveredTcpDevicesEmptyTb4b4b4: Tffa657BooleanTb4b4b4,
Tb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Te6edf3isNetworkScanning Tff7b72&Tff7b72& Te6edf3localNetworkPermissionGranted Tff7b72&Tff7b72& Te6edf3wifiUnavailable Tff7b72&Tff7b72& Te6edf3discoveredTcpDevicesEmpty

Served by rngit 1.5.0 - Generated in 0.05s